<?php 
/**
* 数据库操作类
*/
class Model 
{
	
	public $errno;
	public $error;
	public $db;
	public $where;
	public $table;
	public $fileds = "*";
	public function __construct($table)
	{
		$this->table = $table;
		try{
			$this->db = new PDO("mysql:host=localhost;dbname=school;charset=utf8","root","");

		}catch(PDOException  $e ){
			echo "Error: ".$e;
		}

	}

	public function add($value='')
	{
		# code...
	}

	public function del($value='')
	{
		# code...
	}

	public function save($value='')
	{
		# code...
	}

	public function select($value='')
	{
		$sql = "select ".$this->fileds." from  ".$this->table.$this->where;

		$res= $this->db->query($sql);

		return $res->fetchAll(PDO::FETCH_ASSOC);

	}

	public function where($where)
	{

		$this->where = $where;

		return $this;
	}

	public function limit($value='')
	{

		return $this;
	}

	public function filed($fileds)
	{
		$this->fileds = $fileds;

		return $this;
	}
}









 ?>